Skip to content

fix(playwright): auto-install Playwright browsers via prepare script#1041

Merged
jycouet merged 1 commit intomainfrom
fix/playwright
Apr 5, 2026
Merged

fix(playwright): auto-install Playwright browsers via prepare script#1041
jycouet merged 1 commit intomainfrom
fix/playwright

Conversation

@jycouet
Copy link
Copy Markdown
Contributor

@jycouet jycouet commented Apr 4, 2026

Closes #1038

Description

Add playwright install in prepare script to make sure we are ready to test:e2e

Checklist

  • Update snapshots (if applicable)
  • Add a changeset (if applicable)
  • Allow maintainers to edit this PR
  • I care about what I'm doing, no matter the tool I use (Notepad, Sublime, VSCode, AI...)

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 4, 2026

🦋 Changeset detected

Latest commit: a01f184

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
sv Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 4, 2026

Open in StackBlitz

npx https://pkg.pr.new/svelte-migrate@1041
npx https://pkg.pr.new/sv@1041
npx https://pkg.pr.new/@sveltejs/sv-utils@1041

commit: a01f184

@svelte-docs-bot
Copy link
Copy Markdown

@sacrosanctic
Copy link
Copy Markdown
Contributor

https://docs.npmjs.com/cli/v8/using-npm/scripts

  • prepare (since npm@4.0.0)
  • Runs any time before the package is packed, i.e. during npm publish and npm pack
  • Runs BEFORE the package is packed
  • Runs BEFORE the package is published
  • Runs on local npm install without any arguments
  • Run AFTER prepublish, but BEFORE prepublishOnly
  • NOTE: If a package being installed through git contains a prepare script, its dependencies and devDependencies will be installed, and the prepare script will be run, before the package is packaged and installed.
  • As of npm@7 these scripts run in the background. To see the output, run with: --foreground-scripts.

Is the prepare script really appropriate? Wouldn't this run during CI? (As a side note, pnpm exec playwright install doesn't work on novel flavours of Linux like NixOS)

@jycouet
Copy link
Copy Markdown
Contributor Author

jycouet commented Apr 5, 2026

I guess that if you have e2e tests you will want to have it in CI. And if in your CI you install playwright in a previous step, this will just pick from cache and all good.

I don't know NixOS, I should look 👀. How people will test then?

@sacrosanctic
Copy link
Copy Markdown
Contributor

I don't know NixOS, I should look 👀. How people will test then?

They use a seperate package manager to install it. It was a throwaway comment, not a blocker.

@jycouet
Copy link
Copy Markdown
Contributor Author

jycouet commented Apr 5, 2026

I still want to see the behavior there 👍
Will look later

@jycouet
Copy link
Copy Markdown
Contributor Author

jycouet commented Apr 5, 2026

I installed nixos to see, an I get:

[nix-shell:~/s01]$ npx playwright install
BEWARE: your OS is not officially supported by Playwright; downloading fallback build for ubuntu24.04-x64.
BEWARE: your OS is not officially supported by Playwright; downloading fallback build for ubuntu24.04-x64.
BEWARE: your OS is not officially supported by Playwright; downloading fallback build for ubuntu24.04-x64.
BEWARE: your OS is not officially supported by Playwright; downloading fallback build for ubuntu24.04-x64.
BEWARE: your OS is not officially supported by Playwright; downloading fallback build for ubuntu24.04-x64.
Playwright Host validation warning:
╔══════════════════════════════════════════════════════╗
║ Host system is missing dependencies to run browsers. ║
║ Missing libraries:                                   ║
║     libstdc++.so.6                                   ║
║     libxcb-shm.so.0                                  ║
║     libX11-xcb.so.1                                  ║
║     libXrandr.so.2                                   ║
║     libXcomposite.so.1                               ║
║     libXcursor.so.1                                  ║
║     libXdamage.so.1                                  ║
║     libXi.so.6                                       ║
║     libXext.so.6                                     ║
║     libXfixes.so.3                                   ║
║     libX11.so.6                                      ║
║     libxcb.so.1                                      ║
║     libgtk-3.so.0                                    ║
║     libgdk-3.so.0                                    ║
║     libpangocairo-1.0.so.0                           ║
║     libpango-1.0.so.0                                ║
║     libatk-1.0.so.0                                  ║
║     libcairo-gobject.so.2                            ║
║     libcairo.so.2                                    ║
║     libgdk_pixbuf-2.0.so.0                           ║
║     libgio-2.0.so.0                                  ║
║     libgobject-2.0.so.0                              ║
║     libglib-2.0.so.0                                 ║
║     libXrender.so.1                                  ║
║     libasound.so.2                                   ║
║     libfreetype.so.6                                 ║
║     libfontconfig.so.1                               ║
║     libdbus-1.so.3                                   ║
╚══════════════════════════════════════════════════════╝
    at validateDependenciesLinux (/home/nixos/s01/node_modules/playwright-core/lib/server/registry/dependencies.js:269:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Registry._validateHostRequirements (/home/nixos/s01/node_modules/playwright-core/lib/server/registry/index.js:962:14)
    at async Registry._validateHostRequirementsForExecutableIfNeeded (/home/nixos/s01/node_modules/playwright-core/lib/server/registry/index.js:1084:7)
    at async Registry.validateHostRequirementsForExecutablesIfNeeded (/home/nixos/s01/node_modules/playwright-core/lib/server/registry/index.js:1073:7)
    at async installBrowsers (/home/nixos/s01/node_modules/playwright-core/lib/cli/installActions.js:145:5)
    at async i.<anonymous> (/home/nixos/s01/node_modules/playwright-core/lib/cli/program.js:63:5)

What's really annoying is that Playwright is not doing a great job spiting this gigantic error!
And it's more or less the same if you didn't install, no matter the shell/os.

I'm hesitant to know how good/bad is it to put in prepare script.

@sacrosanctic
Copy link
Copy Markdown
Contributor

Original problem was playwright printing too much junk. Maybe this is more of an upstream issue and we should just print a msg in the console.

@Rich-Harris
Copy link
Copy Markdown
Member

My 2c: if you have e2e tests and you're not running them in CI, you're Doing It Wrong. And if you can't run them in CI because you're using NixOS, then the solution to that is stop using NixOS

@jycouet jycouet merged commit d56ff48 into main Apr 5, 2026
8 checks passed
@jycouet jycouet deleted the fix/playwright branch April 5, 2026 16:19
@github-actions github-actions bot mentioned this pull request Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

install playwright automatically

3 participants